﻿#pragma strict

var anim:Animator;
//状态变量
var moveSpeed:float;
var isBeHit:boolean;
var isAttack:boolean;
var attackType:float; // 攻击类型[0,1]
//状态名称
var moveSpeedName = "moveSpeed";
var isBeHitName = "isBeHit";
var isAttackName = "isAttack";
var attackTypeName = "attackType";


function Start () {
	anim = GetComponent.<Animator>();
}

function Update () {
	Reset();
	BeHit();
	Attack();
	Move();
}

function Reset(){
	anim.SetBool(isBeHitName,false);
	anim.SetBool(isAttackName,false);
}

function BeHit(){
	if(isBeHit){
		isBeHit = false;
		anim.SetBool(isBeHitName,true);
	}
}
function Attack(){
	if(isAttack){
		isAttack = false;
		
		anim.SetFloat(attackTypeName,attackType);
		anim.SetBool(isAttackName,true);
	}
}

function Move(){
	anim.SetFloat(moveSpeedName,moveSpeed);
}